package com.lo23.data.objinterface;


public class DataInterface 
{
   
	private LocalUser localUser;
	
   /**
    * Load from xml file and return a local user
    * 
    * @param path File path to the xml file
    * 
    * @return LocalUser or null if user can't be loaded (no xml file, corrupted etc...)
    */
   public LocalUser getLocalUser(String path)
   {
	   if (localUser == null)  {
		   localUser = new LocalUser();
		   boolean result = localUser.loadProfileXML(path);
		   if (result == true) {
			   return localUser;
		   } else {
			   return null;
		   }
	   } else {
		   return localUser;
	   }
   }
   
   /**
    * @param Login
    * @param Password
    * @return LocalUser The newly created local user
    */
   public LocalUser newUser(String login, String password) 
   {
	   localUser = new LocalUser();
	   localUser.newProfileXML(login, password);
	   localUser.setProfileXML(null);
	   
	   return localUser;
   }
}
